/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: #1a1a1a;
    color: #ffffff;
    overflow: hidden;
    user-select: none;
    cursor: default; /* 默认显示鼠标指针 */
}

/* 屏幕通用样式 */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #2a2a2a 0%, #1a1a1a 100%);
    transition: opacity 0.5s ease;
}

/* 仅显示当前屏幕 */
#settings-screen, #game-screen, #pause-screen, #end-screen {
    opacity: 0;
    pointer-events: none;
}

#start-screen.active,
#settings-screen.active,
#game-screen.active,
#pause-screen.active,
#game-screen.active {
    opacity: 1;
    pointer-events: auto;
    cursor: none; /* 只有活动的游戏界面隐藏鼠标指针 */
}

/* 按钮样式 */
.btn {
    padding: 12px 30px;
    margin: 10px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn.primary {
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    color: #ffffff;
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

/* 开始屏幕样式 */
.logo h1 {
    font-size: 48px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    background: linear-gradient(45deg, #ffffff, #cccccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo p {
    font-size: 18px;
    color: #ff6b6b;
    margin-bottom: 50px;
}

/* 设置屏幕样式 */
.settings-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 30px;
    width: 400px;
    max-width: 90vw;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.setting-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.setting-item label {
    font-size: 16px;
    color: #cccccc;
}

.setting-item select {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* 游戏屏幕样式 */
.game-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 20px 40px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.game-header > div {
    font-size: 20px;
    font-weight: bold;
    color: #ffffff;
}

#time-left {
    color: #ff6b6b;
}

#current-score {
    color: #4ade80;
}

#accuracy {
    color: #60a5fa;
}

.target-area {
    position: fixed;
    width: 300%; /* 增大背景区域以便3D移动 */
    height: 300%;
    left: -100%;
    top: -100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    background-size: 400% 400%;
    animation: gradientAnimation 15s ease infinite;
    transition: transform 0.05s ease-out; /* 平滑移动背景 */
    overflow: hidden;
    transform-style: preserve-3d;
}

/* 3D空间效果 - 添加星星背景 */
.target-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(white 1px, transparent 1px),
        radial-gradient(white 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
    opacity: 0.3;
    z-index: 1;
}

@keyframes gradientAnimation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 加分反馈样式 */
.points-popup {
    position: fixed;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 2000;
    pointer-events: none;
    animation: pointsFloat 0.8s ease-out forwards;
}

@keyframes pointsFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -70%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -100%) scale(1);
    }
}

/* 连击信息样式 */
.streak-message {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #ff4500, #ff8c00);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 32px;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 10px 20px rgba(255, 69, 0, 0.4);
    z-index: 2000;
    pointer-events: none;
    animation: streakAppear 1.5s ease-out forwards;
}

@keyframes streakAppear {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.8) translateY(20px);
    }
    30% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1) translateY(0);
    }
    70% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) scale(1) translateY(-20px);
    }
}

.points-popup.fade-out,
.streak-message.fade-out {
    opacity: 0;
}

/* 准心样式 */
.crosshair {
    position: fixed;
    width: 15px;
    height: 15px;
    pointer-events: none;
    z-index: 1000;
    transition: none; /* 移除过渡效果，使准心移动更流畅 */
    will-change: left, top;
}

/* 经典准心 */
.crosshair.classic::before,
.crosshair.classic::after {
    content: '';
    position: absolute;
    background-color: #ffffff;
}

.crosshair.classic::before {
    width: 2px;
    height: 10px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair.classic::after {
    width: 10px;
    height: 2px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* 圆点准心 */
.crosshair.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ffffff;
}

/* 动态准心 */
.crosshair.dynamic {
    animation: pulse 0.5s infinite;
}

.crosshair.dynamic::before,
.crosshair.dynamic::after {
    content: '';
    position: absolute;
    background-color: #ff6b6b;
}

.crosshair.dynamic::before {
    width: 3px;
    height: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair.dynamic::after {
    width: 12px;
    height: 3px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

/* 气球样式 - 3D效果 */
.target {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: none !important; /* 重要：移除过渡效果，避免干扰点击事件 */
    animation: floatAnimation 4s ease-in-out infinite;
    z-index: 999 !important; /* 提高z-index确保气球在最上层 */
    /* 大幅扩大可点击区域 */
    padding: 20px;
    background-color: transparent;
    pointer-events: auto;
    /* 确保点击区域覆盖整个气球 */
    border-radius: 50%;
    /* 添加轮廓以帮助调试（可在调试后移除） */
    outline: 1px solid transparent;
}

/* 气球主体 */
.target::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), transparent);
    box-shadow: 0 0 20px rgba(255,255,255,0.2);
    pointer-events: none;
    z-index: -1;
}

/* 气球底部小三角 */
.target::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    pointer-events: none;
    z-index: -1;
}

/* 不同类型的气球 */
.target.type1 {
    width: 80px;
    height: 115px; /* 增加高度以包含底部小三角 */
}

.target.type1::before {
    width: 80px;
    height: 100px;
    background-color: #ff6b6b;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.target.type1::after {
    border-top: 15px solid #ff6b6b;
}

.target.type2 {
    width: 60px;
    height: 92px; /* 增加高度以包含底部小三角 */
}

.target.type2::before {
    width: 60px;
    height: 80px;
    background-color: #ff8e53;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.target.type2::after {
    border-top: 12px solid #ff8e53;
}

.target.type3 {
    width: 40px;
    height: 70px; /* 增加高度以包含底部小三角 */
}

.target.type3::before {
    width: 40px;
    height: 60px;
    background-color: #feca57;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.target.type3::after {
    border-top: 10px solid #feca57;
}

.target.type4 {
    width: 30px;
    height: 53px; /* 增加高度以包含底部小三角 */
}

.target.type4::before {
    width: 30px;
    height: 45px;
    background-color: #48dbfb;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}

.target.type4::after {
    border-top: 8px solid #48dbfb;
}

/* 气球浮动动画 */
@keyframes floatAnimation {
    0%, 100% { transform: translate(-50%, -50%) translateY(0) rotate(0deg); }
    25% { transform: translate(-50%, -50%) translateY(-10px) rotate(2deg); }
    50% { transform: translate(-50%, -50%) translateY(0) rotate(0deg); }
    75% { transform: translate(-50%, -50%) translateY(-10px) rotate(-2deg); }
}

/* 气球爆炸效果 */
.target.hit {
    animation: popEffect 0.3s forwards ease-out;
    /* 确保爆炸时不响应点击 */
    pointer-events: none;
    /* 确保动画优先于其他样式 */
    transition: none !important;
    animation-fill-mode: forwards !important;
}

@keyframes popEffect {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    40% { 
        transform: translate(-50%, -50%) scale(1.6); 
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) scale(0); 
        opacity: 0;
    }
}
    }
}

/* 增强爆炸时的视觉效果 */
.target.hit::before {
    animation: popFlash 0.3s forwards ease-out;
}

@keyframes popFlash {
    0% { box-shadow: 0 0 20px rgba(255,255,255,0.2); }
    50% { 
        box-shadow: 0 0 40px rgba(255,255,255,0.8), 
                    inset 0 0 20px rgba(255,255,255,0.6); 
    }
    100% { box-shadow: 0 0 0 rgba(255,255,255,0); }
}

/* 暂停按钮 */
.pause-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    z-index: 20;
}

.pause-btn::after {
    content: ' (ESC)';
    font-size: 12px;
    opacity: 0.8;
}

.pause-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 结束屏幕样式 */
.results {
    background: rgba(0, 0, 0, 0.3);
    padding: 40px;
    border-radius: 10px;
    margin-bottom: 40px;
    width: 500px;
    max-width: 90vw;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.result-item:last-child {
    border-bottom: none;
    margin-bottom: 30px;
    padding-bottom: 0;
}

.result-item .label {
    font-size: 18px;
    color: #cccccc;
}

.result-item .value {
    font-size: 24px;
    font-weight: bold;
    color: #4ade80;
}

.rating .value {
    color: #feca57;
    font-size: 32px;
    text-transform: uppercase;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 36px;
    }
    
    .game-header {
        padding: 15px 20px;
    }
    
    .game-header > div {
        font-size: 16px;
    }
    
    .settings-container,
    .results {
        width: 90vw;
        padding: 20px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 16px;
    }
    
    .result-item .label {
        font-size: 16px;
    }
    
    .result-item .value {
        font-size: 20px;
    }
    
    .rating .value {
        font-size: 24px;
    }
}

/* 加载动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active h2 {
    animation: fadeIn 0.5s ease;
}

.screen.active .settings-container,
.screen.active .results {
    animation: fadeIn 0.7s ease;
}

.screen.active .btn {
    animation: fadeIn 0.9s ease;
}